
<script>
	//  子组件接受数据
	 export let items;
	 import { getContext,onMount,createEventDispatcher } from 'svelte';

	const answer = getContext('answer');
    onMount(()=>{
		// 获取父级生命answer
		  console.log(answer);
	})

	// 事件派发，类似于事件总线
	// 也类似于vue中emit,on做父子通信
	const dispatch = createEventDispatcher();
</script>
<ul>
	<!-- 条件语句each -->
    {#each items as item}
		<li class="fancy">
            <!-- 具名插槽 -->
			<slot name="item" item={item}></slot>
		</li>
	{/each}
</ul>

<button on:click="{() => dispatch('notify', 'detail value')}">Fire Event</button>